package test1224;

public class Test12 {
    public static void m12(int[] arr) {
        int one = 0;
        int five = 0;

        for (int i = 0; i < arr.length; i++) {
            if (arr[i] == 5) {
                five = i;
            }
            if (arr[i] == 1) {
                one = i;
            }
        }
        int temp = arr[one];
        arr[one] = arr[five];
        arr[five] = temp;
        System.out.println(arr[one]);
        System.out.println(arr[five]);
    }
    public static void main(String[] args) {
        // 根据方法的调用需求实现方法
        // 互换元素1和元素5的位置
        int[] arr = {1,2,3,4,5};
        m12(arr);
    }
}